//
//  AppealSearchViewController.m
//  Utils
//
//  Created by enghou on 2018/6/23.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "AppealSearchViewController.h"
#import "AppealTypeViewController.h"
#import "AppealTypeListModel.h"
#import "LocalPersistent.h"
@interface AppealSearchViewController ()

//@property(nonatomic,strong)NSArray *appealTypes;
//@property(nonatomic,strong)PropertyDictItemModel *appealModel;
//
//@property(nonatomic,strong)NSArray *appealSource;
//@property(nonatomic,strong)PropertyDictItemModel *appealSourceModel;

@property (weak, nonatomic) IBOutlet UITextField *occurPlaceField;

@end

@implementation AppealSearchViewController

-(instancetype)init{
    return (AppealSearchViewController *)[VCLoader vcWithName:@"AppealSearchViewController"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

//诉求类型的点击事件
-(void)showScales{
    AppealTypeViewController *appealTypeVC = [[AppealTypeViewController alloc]init];
    appealTypeVC.title = @"诉求类型";
    appealTypeVC.path = @"/mobile/comprehensiveGovernance/appeal/getAllAppealType.action";
    appealTypeVC.itemCls = @"AppealTypeListModel";
    appealTypeVC.theDelete = self;
    [self push:appealTypeVC];
}

-(void)fetchModel:(id)model{
    if ([model isKindOfClass:[AppealSubTypeItemModel class]]) {
        self.scaleId = [(AppealSubTypeItemModel *)model subTid];
        self.eventScaleLabel.text = [(AppealSubTypeItemModel *)model name];
    }
}

//诉求来源
-(void)showSources{
    [self commonAlertWithContent:@"诉求来源" choosenBlock:^(PropertyDictItemModel *model) {
        self.sourceId = model.ids;
        self.sourceLabel.text = model.displayName;
    } getList:^(NSArray *list) {
        self.eventSource = list;
    }];
}

-(void)queryAction{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"mobileAppealSearchVo.name"] = self.eventNameField.text;
    if (self.scaleId.length > 0) {
        param[@"mobileAppealSearchVo.type"] = self.scaleId;
    }
    if (self.sourceId.length > 0) {
        param[@"mobileAppealSearchVo.source"] = self.sourceId;
    }
    NSString *orgId = [[LocalPersistent sharedInstance]contentForKey:@"orgId"];
    if (orgId) {
        param[@"mobileAppealSearchVo.orgId"] = orgId;
    }
    param[@"mobileAppealSearchVo.place"] = self.occurPlaceField.text;
    param[@"mobileAppealSearchVo.startDate"] = self.beginTimeField.text;
    param[@"mobileAppealSearchVo.endDate"] = self.endTimeField.text;
    if ([self.theDelete respondsToSelector:@selector(fetchModel:)]) {
        [self.theDelete fetchModel:param];
    }
    [self pop];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
